package com.project.yunfeiblog.controller;


import com.project.yunfeiblog.entity.User;
import com.project.yunfeiblog.service.impl.UserServiceImpl;
import com.project.yunfeiblog.utils.HandleResult;
import com.project.yunfeiblog.utils.ResposeResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @RequestMapping("/findAll")
    public ResposeResult findAll(){
        List<User> userList = userService.findAll();
        log.error("userList is {}", userList);
        return new ResposeResult(HandleResult.SUCCESS.getErrorCode(), HandleResult.SUCCESS.getErrorMsg(), userList);
    }

    @RequestMapping("/test")
    public ResposeResult test() {
        return new ResposeResult(HandleResult.SUCCESS.getErrorCode(), HandleResult.SUCCESS.getErrorCode(), "欢迎来到云飞博客");
    }
}
